package com.mec.beans.y2012.coreservlet;

public class SaleEntry {

	private String itemId = "unkown";
	private double discountCode = 1.0;
	private int numItems = 0;
	
	public double getItemCost(){
		double cost;
		if(itemId.equals("a1234")){
			cost = 12.99 * getDiscountCode();
		}else{
			cost = -9999;
		}
		//
		return roundToPennies(cost);
	}
	
	private double roundToPennies(double cost){
		return Math.floor(cost * 100)/ 100.0;
	}
	
	public double getTotalCost(){
		return getItemCost() * getNumItems();
	}
	public String getItemId() {
		return itemId;
	}
	public void setItemId(String itemId) {
		if(null != itemId){
			this.itemId = itemId;
		}else{
			this.itemId = "unKnown";
		}
	}
	public double getDiscountCode() {
		return discountCode;
	}
	public void setDiscountCode(double discountCode) {
		this.discountCode = discountCode;
	}
	public int getNumItems() {
		return numItems;
	}
	public void setNumItems(int numItems) {
		this.numItems = numItems;
	}
	
}
